import java.awt.image.BufferedImage;


public class Heli extends Sprite {

	private static final long	serialVersionUID	= 1L;

	public Heli(BufferedImage[] i, double x, double y, long delay, GamePanel p) {
		super(i, x, y, delay, p);
	}

	@Override
	public void doLogic(long delta) {
		super.doLogic(delta);
		
		if(getX()<0){
			setHorizontalSpeed(0);
			x = 0;
		}

		if(getY()<0){
			setHorizontalSpeed(0);
			y = 0;
		}
		
		if(getX()+getWidth()>parent.getWidth()){
			setVerticalSpeed(0);
			x = parent.getWidth()-getWidth();
		}
		
		if(getY()+getHeight()>parent.getHeight()){
			setVerticalSpeed(0);
			y = parent.getHeight()-getHeight();
		}
		
	}

	@Override
	public boolean collidedWith(Sprite s) {

    if(remove){
    	return false;
    }
		
		if(this.intersects(s)){
			
			if(s instanceof Rocket){
				parent.createExplosion((int)getX(),(int)getY());
				parent.createExplosion((int)s.getX(),(int)s.getY());
				remove   = true;
				s.remove = true;
				return true;
			}			
			
		}
		
		
		return false;
	}

	
}

